#!/bin/bash

WD=$(dirname $0)
pushd $WD > /dev/null

function poistu {
	popd > /dev/null
	exit $1
}

gcc -ggdb -fPIC -c dev/xfire/*.c $* || poistu $?
gcc -ggdb -fPIC -c dev/xfire/packet_creation/*.c $* || poistu $?
gcc -ggdb -fPIC -c dev/shared/*.c $* || poistu $?
gcc -shared -o libopenfire.so *.o || poistu $?
cp -f libopenfire.so release/libopenfire.so
cp -f libopenfire.so release/app/libopenfire.so
cp libopenfire.so release/libopenfire-`date +%y%m%d%H%M%S`.so
rm *.o
./headergen.py
cp release/include/*.h /usr/include/openfire/
poistu 0

